package com.keepsport.keepsportapi.controller;

import com.keepsport.keepsportapi.config.SystemConfig;
import com.keepsport.keepsportapi.dto.ActivityAddDto;
import com.keepsport.keepsportapi.service.intf.ActivityService;
import com.keepsport.keepsportapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@Api(tags = "活动")
@CrossOrigin
@RequestMapping("/api/activity/")
public class ActivityController {
    @Resource
    private ActivityService service;
    @ApiOperation(value ="添加活动")
    @PostMapping("add.do")
    public R add(@RequestBody ActivityAddDto dto, HttpServletRequest request){
        return service.save(dto,request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }
    @ApiOperation(value = "审核活动")
    @GetMapping("audit.do")
    public R audit(int id,int flag){
        return service.audit(id,flag);
    }
    @ApiOperation(value ="查询活动")

    @GetMapping("query.do")
    public R query(int type){
        return service.query(type);
    }
}
